package springboot.http;

import java.util.Arrays;
import java.util.Random;

/**
 * wxWork
 * springboot.http
 * Created by Blue on 2021/12/27.
 */
public class num {
	public static void main(String[] args) {
		int[][] list = re();
		
		while (ss(list)) {
			System.out.println(Arrays.deepToString(list));
		}
		for (int[] ints : list) {
			for (int j = 0; j < list.length; j++) {
				System.out.print(ints[j]);
			}
			System.out.println();
		}
	}
	
	static boolean ss(int[][] list) {
		
		System.out.println("list = " + Arrays.deepToString(list));
		int index = 0;
//		检查行
		for (int[] ints : list) {
			for (int j = 0; j < list.length; j++) {
				index += ints[j];
				System.out.println("intsj = " + ints[j]);
			}
			if (index != 9) {
				return false;
			}
		}
		index = 0;
		for (int i = 0; i < list.length; i++) {
			for (int[] ints : list) {
				index += ints[i];
				System.out.println("intsi = " + ints[i]);
			}
		}
		return index == 9;
	}
	
	static int[][] re() {
		int[][] list = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
		Random random = new Random(1000);
		for (int a = 1; a < 10; a++) {
			int i1 = random.nextInt(3);
			int i2 = random.nextInt(3);
			while (list[i1][i2] == 0) {
				System.out.println("a = " + a);
				list[i1][i2] = a;
				System.out.println("list[i1][i2] = " + list[i1][i2]);
				i1 = random.nextInt(3);
				i2 = random.nextInt(3);
			}
		}
		while (ss(list)) {
			System.out.println();
		}
		return list;
	}
	
}
